Carbon


SetThreadTerminator

Header: Threads.h Carbon status: Supported

Installs a custom thread-termination function for a thread.

OSErr SetThreadTerminator (
    ThreadID thread, 
    ThreadTerminationUPP threadTerminator, 
    void *terminationProcParam
);
thread

The thread ID of the thread to associate with the thread-termination function.

threadTerminator

A pointer to the thread-termination function.

terminationProcParam

A pointer to a thread-specific parameter that you pass to the thread-termination function.

function result

A result code.

DISCUSSION

The Thread Manager calls the custom termination function whenever the specified thread completes execution of its code or when you manually dispose of the thread with the DisposeThread function.

You can pass a different terminationProcParam parameter to each thread, which allows you to write a single, application-wide custom thread-termination function and then pass any thread-specific information when the Thread Manager calls the termination function for that thread.

Do not pass a function descriptor as the threadTerminator parameter to the SetThreadTerminator function. As with all Thread Manager functions that pass a function pointer, you must pass the address of the function, not the address of a function descriptor. You are required to use function descriptors when you write code in the PowerPC instruction set that passes a functionís address to code that might be in the 680x0 instruction set. However, the threads in your application must all be in the same instruction setó680x0 or PowerPC. Therefore, the function identified by the threadTerminator parameter is by definition in the same instruction set as the SetThreadTerminator function and a function descriptor is not required.

For more information on the custom thread-termination function, see the ThreadTerminationProcPtr function.

AVAILABILITY

Supported in Carbon. Available in CarbonLib 1.0 and later when ThreadsLib 1.0 or later is installed. Exported by CarbonLib 1.0 and later and by ThreadsLib 1.0 and later.


© 2000 Apple Computer, Inc. — (Last Updated 3/8/2000)